package netWork;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-17
 * Time: 17:26
 */
public class UdpDictServer extends UdpEchoServer{
    Map<String,String> dict = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);
        dict.put("cat","小猫");
        dict.put("dog","小狗");
        dict.put("pig","小猪");
        dict.put("bird","小鸟");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"您查找的单词在该字典中不存在");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer udpDictServer = new UdpDictServer(9906);
        udpDictServer.run();
    }
}
